﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class RFInboundService : IRFInboundService
    {
        public string BatchExecPutawayByLpn(string toLoc, List<string> lpnID, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new RFReceiptDetailBLL(pubParasInfo).BatchExecPutawayByLpn(toLoc, lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return result;
        }

        public string ExecPutawayByLpn(RFPutawayInfo rfPutawayInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new RFReceiptDetailBLL(pubParasInfo).ExecPutawayByLpn(rfPutawayInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return result;
        }

        public bool ExecReceivingByAsnLpn(RFReceiptDetailInfo rfReceiptDetailInfo, PubParasInfo pubParasInfo)
        {
            bool result = false;
            try
            {
                result = new RFReceiptDetailBLL(pubParasInfo).ExecReceivingByAsnLpn(rfReceiptDetailInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "RFInboundService异常");
            }
            return result;
        }

        public bool ExecReceivingByLpn(string receiptID, List<RFReceiptDetailInfo> rfReceiptDetailInfos, PubParasInfo pubParasInfo)
        {
            bool result = false;
            try
            {
                result = new RFReceiptDetailBLL(pubParasInfo).ExecReceivingByLpn(receiptID, rfReceiptDetailInfos);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return result;
        }

        public DataSet GetAllAvailableReceiptInfo(PubParasInfo pubParasInfo)
        {
            DataSet ds = null;
            try
            {
                ds = new RFReceiptDetailBLL(pubParasInfo).GetAllAvailableReceiptInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return ds;
        }

        public RFPutawayInfo GetRFPutawayInfoByLpn(string lpnID, PubParasInfo pubParasInfo)
        {
            RFPutawayInfo rfPutawayInfo = null;
            try
            {
                rfPutawayInfo = new RFReceiptDetailBLL(pubParasInfo).GetRFPutawayInfoByLpn(lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return rfPutawayInfo;
        }

        public List<RFReceiptDetailInfo> GetRFReceiptDetailInfoByLpn(string receiptID, string lpnID, PubParasInfo pubParasInfo)
        {
            List<RFReceiptDetailInfo> rfReceiptDetailInfos = null;
            try
            {
                rfReceiptDetailInfos = new RFReceiptDetailBLL(pubParasInfo).GetRFReceiptDetailInfoByLpn(receiptID, lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return rfReceiptDetailInfos;
        }

        public RFReceiptInfo GetRFReceiptInfoByID(string receiptID, PubParasInfo pubParasInfo)
        {
            RFReceiptInfo rfReceiptInfo = null;
            try
            {
                rfReceiptInfo = new RFReceiptDetailBLL(pubParasInfo).GetRFReceiptInfoByID(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return rfReceiptInfo;
        }

        public RFReceiptInfo GetRFReceiptInfoByLpnID(string lpnID, PubParasInfo pubParasInfo)
        {
            RFReceiptInfo rfReceiptInfo = null;
            try
            {
                rfReceiptInfo = new RFReceiptDetailBLL(pubParasInfo).GetRFReceiptInfoByLpnID(lpnID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundService异常");
            }
            return rfReceiptInfo;
        }

        public RFReceiptValidationInfo GetRFReceiptValidationByAsnIDAndSkuBarCode(string receiptID, string ownerID, string skuBarCode, PubParasInfo pubParasInfo)
        {
            RFReceiptValidationInfo rfReceiptValidationInfo = null;
            try
            {
                rfReceiptValidationInfo = new RFReceiptDetailBLL(pubParasInfo).GetRFReceiptValidationByAsnIDAndSkuBarCode(receiptID, ownerID, skuBarCode);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "RFInboundService异常");
            }
            return rfReceiptValidationInfo;
        }
    }
}

